// model/DeviceAlarm.dart
class DeviceAlarm {
  late int? createBy;
  late String? createTime;
  late int? updateBy;
  late String? updateTime;
  late String? remark;
  late int? camId;
  late String? camName;
  late int? deviceId;
  late int? motionDetection;
  late int? motionDetectionSetting;
  late int? defenseSetting;
  late int? alarmRecord;
  late int? sensitivity;
  late int? indoorAlarmSound;
  late int? doorLockDelay;
  late int? camType;
  late int? camStatus;

  DeviceAlarm({
    this.createBy,
    this.createTime,
    this.updateBy,
    this.updateTime,
    this.remark,
    this.camId,
    this.camName,
    this.deviceId,
    this.motionDetection,
    this.motionDetectionSetting,
    this.defenseSetting,
    this.alarmRecord,
    this.sensitivity,
    this.indoorAlarmSound,
    this.doorLockDelay,
    this.camType,
    this.camStatus,
  });

  // 从JSON数据创建DeviceAlarm实例的工厂方法
  factory DeviceAlarm.fromJson(Map<String, dynamic> json) {
    return DeviceAlarm(
      createBy: json['createBy'] as int?,
      createTime: json['createTime'] as String?,
      updateBy: json['updateBy'] as int?,
      updateTime: json['updateTime'] as String?,
      remark: json['remark'] as String?,
      camId: json['camId'] as int?,
      camName: json['camName'] as String?,
      deviceId: json['deviceId'] as int?,
      motionDetection: json['motionDetection'] as int?,
      motionDetectionSetting: json['motionDetectionSetting'] as int?,
      defenseSetting: json['defenseSetting'] as int?,
      alarmRecord: json['alarmRecord'] as int?,
      sensitivity: json['sensitivity'] as int?,
      indoorAlarmSound: json['indoorAlarmSound'] as int?,
      doorLockDelay: json['doorLockDelay'] as int?,
      camType: json['camType'] as int?,
      camStatus: json['camStatus'] as int?,
    );
  }

  // 将DeviceAlarm实例转换为JSON格式
  Map<String, dynamic> toJson() {
    return {
      'createBy': createBy,
      'createTime': createTime,
      'updateBy': updateBy,
      'updateTime': updateTime,
      'remark': remark,
      'camId': camId,
      'camName': camName,
      'deviceId': deviceId,
      'motionDetection': motionDetection,
      'motionDetectionSetting': motionDetectionSetting,
      'defenseSetting': defenseSetting,
      'alarmRecord': alarmRecord,
      'sensitivity': sensitivity,
      'indoorAlarmSound': indoorAlarmSound,
      'doorLockDelay': doorLockDelay,
      'camType': camType,
      'camStatus': camStatus,
    };
  }

  @override
  String toString() {
    return 'DeviceAlarm{'
        'camId: $camId, '
        'camName: $camName, '
        'motionDetection: $motionDetection, '
        'defenseSetting: $defenseSetting, '
        'alarmRecord: $alarmRecord'
        '}';
  }
}